package ds.factcom.model;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

import ds.factcom.domain.invoice.Invoice;
import ds.factcom.exception.ClientHasNotInvoicesPending;

public class PaymentItemTableModel extends AbstractTableModel{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String[] columns = {"NUMERO DE FACTURA", "MONTO NETO", "TOTAL"};
	private final PaymentModel paymentModel;
	private List<Invoice> items;
	
	public PaymentItemTableModel(PaymentModel paymentModel){
		this.paymentModel=paymentModel;
		items = this.paymentModel.getInvoices();
	}
	
	@Override
	public int getColumnCount() {
		return columns.length;
	}

	@Override
	public int getRowCount() {
		return items.size();
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		Object object = null;
		switch (columnIndex) {
		case 0:
			object = items.get(rowIndex).getId();
			break;
		case 1:
			object = items.get(rowIndex).getMountNet();
			break;
		case 2:
			object = items.get(rowIndex).getMountAbsoluty();
			break;
		case 3:
		default:
			break;
		}
		return object;
	}
	
	@Override
	public String getColumnName(int column) {
		return columns[column];
	}

	public void setItems(List<Invoice> items) {
		this.items = items;
	}
	
}
